<?php
/**
 * Created by PhpStorm.
 * User: W
 * Date: 2019/1/7
 * Time: 14:13
 */

namespace app\sports_admin\controller;
use app\sports_admin\model\FeedBack as FeedBackModel;
use think\Request;
use app\sports_admin\service\Feedback as FeedbackService;
use app\sports_admin\vaildate\Feedback as FeedbackVaildate;
class FeedBack extends Base
{
    protected $beforeActionList = [
        'isResource'=>['index,feedbacklist,message'],
        'operationSelect'=>['index,feedbacklist,message']
    ];
    //信息反馈页面
    public function index()
    {
        return view("index");
    }
    //信息反馈列表
    public function feedBackList()
    {
        $params = Request::instance()->only(['page','rows','sort','sortOrder','searchName']);
        $page = intval($params['page']) ? intval($params['page']) : 1;
        $rows = intval($params['rows']) ? intval($params['rows']) : 15;
        $sort = trim($params['sort']) ? trim($params['sort']) : 'id';
        $sortOrder = trim($params['sortOrder']) ? trim($params['sortOrder']) : 'asc';
        $searchName = trim($params['searchName']);
        $result = FeedBackModel::feedBackList($page,$rows,$sort,$sortOrder,$searchName);
        return $result;
    }
    //反馈详情
    public function detail()
    {
        $data = FeedbackService::detail();
        return view('detail',compact('data'));
    }
    //回复页面
    public function before_reply()
    {
        $data = FeedbackService::detail();
        return view('reply',compact('data'));
    }
    //反馈回复
    public function reply()
    {
        (new FeedbackVaildate())->reply();
        return FeedbackService::reply();
    }
    //删除反馈
    public function delete()
    {
        (new FeedbackVaildate())->go_check();
        return FeedbackService::delete();
    }
}